<script type="text/javascript" th:src="@{#{webjars.zxcvbn.js}}"></script>
<script type="text/javascript" th:src="@{#{webjars.jqueryui.js}}"></script>
<script type="text/javascript" th:src="@{#{webjars.jquerycookie.js}}"></script>
<script src="//www.google.com/recaptcha/api.js" async defer th:if="${recaptchaSiteKey}"></script>
<script th:src="@{#{webjars.bootstrapmin.js}}"></script>

<script th:src="@{#{webjars.headmin.js}}"></script>
<script th:src="@{#{webjars.storemin.js}}"></script>
<script type="text/javascript" th:src="@{${#themes.code('cas.javascript.file')}}"></script>

<script th:inline="javascript">
head.ready(document, function () {
    if (!window.jQuery) {
    	var jqueryUrl = /*[[@{#{webjars.jquerymin.js}}]]*/; 
        head.load(jqueryUrl, loadjQueryUI);
    } else {
        notifyResourcesAreLoaded(resourceLoadedSuccessfully);
    }
});

function loadjQueryUI() {
	var jqueryUrl = /*[[@{#{webjars.jqueryui.js}}]]*/; 
	head.load(jqueryUrl, loadjQueryCookies);
}

function loadjQueryCookies() {
	var jqueryUrl = /*[[@{#{webjars.jquerycookie.js}}]]*/; 
	head.load(jqueryUrl, notifyResourcesAreLoaded(resourceLoadedSuccessfully));
}

function notifyResourcesAreLoaded(callback) {
    if (typeof callback === "function") {
        callback();
    }
}
</script>

<script th:inline="javascript">
    /*<![CDATA[*/

    var trackGeoLocation = /*[[${trackGeoLocation}]]*/ === "true";

    var googleAnalyticsTrackingId = /*[[${googleAnalyticsTrackingId}]]*/;

    if (googleAnalyticsTrackingId != null && googleAnalyticsTrackingId != '') {
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

        ga('create', googleAnalyticsTrackingId, 'auto');
        ga('send', 'pageview');
    }

    /*]]>*/
</script>

<script type="text/javascript" th:if="${recaptchaSiteKey != null AND recaptchaInvisible != null AND recaptchaSiteKey AND recaptchaInvisible}" th:inline="javascript">
    function onSubmit(token) {
        $('#fm1').submit();
    }
</script>
